home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270
/
hndkbd.c
< prev
next >
Wrap
Text File
|
1991-06-03
|
21KB
|
1,011 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#define __SEG__ 3270seg2
#include "maclib.h"
#include "termdef.h"
#include "globals.h"
#define IAC 255 /* interpret as command: */
#define EOR 239 /* end of record (transparent mode) */
static char inschar = 0;
extern short maxcnt, maxoff, scrhsize;
extern char pend_conn;
short cinsert();
short getattr();
short firstattr();
hndkbd(chr, shift)
unsigned char chr, shift;
{
register unsigned char c;
register unsigned char typ, val, geflag, alphaflag;
c = chr; /* get character */
/* define type, value, and geflag for key */
typ = kbtyp[c];
alphaflag = geflag = 0;
if (typ & 0x80) geflag = 1;
if (typ & 0x40) alphaflag = 1;
typ &= 0x3f;
if (aplmode) val = kbapl[c];
else {
val = kbstd[c];
if ((val == 0xad) || (val == 0xbd)) geflag = 1;
else geflag = 0;
}
/* check if key should be ignored */
if (val == 0) return;
/* check if alpa lock needs to be applied */
if (alphaflag && shift) val += 0x40;
/* process key based on type code */
switch(typ) {
case 1: datakey(val, geflag);
break;
case 2: attnkey(val);
break;
case 3: funckey(val);
break;
default: break;
}
}
datakey(val, geflag)
unsigned char val, geflag;
{
register short attroff;
register short newattr;
register short i;
register unsigned char inpskip;
if (!fmtscrn) { /* unformatted screen */
if (insmode || inschar) if (cinsert()) { /* if insert, make room */
kerr(1);
beep(); /* error if no room */
apikberr = sendInsErr;
return;
}
newattr = atrbuff[curadr] & 0xbf00;
if (geflag) newattr |= 0x4000;
newchar(curadr, val, newattr, 0);
newwrite(0);
curadr++;
if (curadr == maxcnt) curadr = 0;
newcur();
kerr(0);
return;
}
/* else formatted screen */
if (atrbuff[curadr] & 0x8000) { /* cursor on attribute byte */
kerr(2);
beep();
apikberr = sendAttrErr;
return;
}
attroff = getattr(curadr);
if (atrbuff[attroff] & 0x2000) { /* protected */
kerr(2);
beep();
apikberr = sendProtErr;
return;
}
if (insmode || inschar) if (cinsert()) { /* if insert, make room */
kerr(1);
beep(); /* error if no room */
apikberr = sendInsErr;
return;
}
newattr = atrbuff[curadr] & 0xbf00; /* update buffer and display */
if (geflag) newattr |= 0x4000;
newchar(curadr, val, newattr, atrbuff[attroff]);
newwrite(0);
atrbuff[attroff] |= 0x0100; /* set MDT bit */
inpskip = 0;
for (i=0; i < maxcnt; i++) { /* find next character position */
curadr++;
if (curadr == maxcnt) curadr = 0;
if (atrbuff[curadr] & 0x8000) {
/* after auto-skip, must find next unprotected field */
if (inpskip) inpskip = (atrbuff[curadr] & 0x2000) != 0;
else inpskip = (atrbuff[curadr] & 0x3000) == 0x3000;
continue;
}
if (inpskip == 0) break;
}
newcur();
kerr(0);
}
attnkey(val)
unsigned char val;
{
short attroff, i;
rdaid = val; /* save aid code for read buffer */
if ((val >= 0x6b) && (val <= 0x6e)) { /* handle short read */
if (val == 0x6d) { /* CLEAR erases screen */
clrscn();
invldscr();
}
if (insmode && cs.insreset) {
insmode = 0;
newstat();
}
readbuff[0] = 0xd7;
readbuff[5] = val;
rbsize = 6;
if (tcpflg) {
readbuff[rbsize++] = IAC;
readbuff[rbsize++] = EOR;
}
senddata(0xf6, rbsize-3, readbuff+3, 1);
return;
}
if (val == 0xf0) { /* test request read */
if (insmode && cs.insreset) {
insmode = 0;
newstat();
}
readbuff[0] = 0xd7;
readbuff[5] = 0x01;
readbuff[6] = 0x6c;
readbuff[7] = 0x61;
readbuff[8] = 0x02;
rbsize = 9;
rdmod(0); /* append modified data */
return;
}
if (val == 0x7e) { /* cursor select */
if (!fmtscrn) {
kerr(2);
beep();
apikberr = sendAIDErr;
return;
}
attroff = getattr(curadr);
i = atrbuff[attroff] & 0x0c00;
if ((i == 0) || (i == 0x0c00)) {
kerr(2);
beep();
apikberr = sendAIDErr;
return;
}
i = attroff + 1;
if (i == maxcnt) {
kerr(2);
beep();
apikberr = sendAIDErr;
return;
}
switch(chrbuff[i]) {
case 0x00: /* space and null */
case 0x40:
break;
case 0x50: /* ampersand */
val = 0x7d;
break;
case 0x6f: /* question mark */
newchar(i, 0x6e, atrbuff[i] & 0xbf00,
atrbuff[attroff]);
newwrite(0);
atrbuff[attroff] |= 0x0100; /* set MDT */
kerr(0);
return;
case 0x6e: /* greater than */
newchar(i, 0x6f, atrbuff[i] & 0xbf00,
atrbuff[attroff]);
newwrite(0);
atrbuff[attroff] &= 0xfeff; /* reset MDT */
kerr(0);
return;
default:
kerr(2);
beep();
apikberr = sendAIDErr;
return;
}
kerr(0);
}
/* normal read-modified */
if (insmode && cs.insreset) {
insmode = 0;
newstat();
}
rdmcmd(val);
}
rdmcmd(val) /* read-modified issued */
unsigned char val;
{
char lp_read;
unsigned char addrbuff[2];
short copylen;
lp_read = (val == 0x7e);
readbuff[0] = 0xd7;
readbuff[5] = val;
rbsize = 6;
if ((val == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
/* append two-byte cursor address */
ebcaddr(addrbuff, curadr);
copylen = 2;
tcpmovmem(addrbuff, readbuff+rbsize, ©len);
rbsize += copylen; /* append modified data */
rdmod(lp_read);
}
rdmacmd(val) /* read-modified all issued */
unsigned char val;
{
unsigned char addrbuff[2];
short copylen;
readbuff[0] = 0xd7;
readbuff[5] = val;
rbsize = 6;
if ((val == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
/* append two-byte cursor address */
ebcaddr(addrbuff, curadr);
copylen = 2;
tcpmovmem(addrbuff, readbuff+rbsize, ©len);
rbsize += copylen; /* append modified data */
rdmod(0);
}
funckey(val)
unsigned char val;
{
unsigned char t;
register unsigned char prot;
register short a, attroff, b, chroff, i, next;
switch(val) {
case 1: curadr -= scrhsize; /* up */
if (curadr < 0) curadr += maxcnt;
newcur();
break;
case 2: curadr += scrhsize; /* down */
if (curadr > maxoff) curadr -= maxcnt;
newcur();
break;
case 3: curadr--; /* left */
if (curadr < 0) curadr = maxoff;
newcur();
break;
case 4: curadr++; /* right */
if (curadr > maxoff) curadr = 0;
newcur();
break;
case 5: if (!fmtscrn) { /* tab */
curadr = 0;
newcur();
return;
}
if (atrbuff[curadr] & 0x8000) /* initial prot value */
prot = (atrbuff[curadr] & 0x2000) != 0;
else prot = 1;
a = curadr + 1;
if (a == maxcnt) a = 0; /* loop from next position */
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000)
prot = (atrbuff[a] & 0x2000) != 0;
else if (!prot) {
curadr = a;
newcur();
return;
}
a++;
if (a == maxcnt) a = 0;
}
curadr = 0;
newcur();
break;
case 6: if (!fmtscrn) { /* backtab */
curadr = 0;
newcur();
return;
}
a = curadr - 1; /* start at previous position */
if (a < 0) a = maxoff;
chroff = -1; /* no character yet */
for (i=0; i <= maxcnt; i++) { /* find unprotected character */
if (atrbuff[a] & 0x8000) { /* attribute */
if (atrbuff[a] & 0x2000) chroff = -1;
else if (chroff > 0) {
curadr = chroff;
newcur();
return;
}
}
else chroff = a;
a--;
if (a < 0) a = maxoff;
}
curadr = 0;
newcur();
break;
case 7: if (!fmtscrn) { /* newline */
curadr = ((curadr / scrhsize) + 1) * scrhsize;
if (curadr == maxcnt) curadr = 0;
newcur();
return;
}
a = ((curadr / scrhsize) + 1) * scrhsize;
if (a == maxcnt) a = 0;
if (!(atrbuff[a] & 0x8000)) /* set prot for first char. */
prot = (atrbuff[getattr(a)] & 0x2000) != 0;
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000) prot = (atrbuff[a] & 0x2000) != 0;
else if (!prot) {
curadr = a;
newcur();
return;
}
a++;
if (a == maxcnt) a = 0;
}
curadr = 0;
newcur();
break;
case 8: if (!fmtscrn) { /* home */
curadr = 0;
newcur();
return;
}
a = 0;
if (!(atrbuff[a] & 0x8000)) /* set prot for first char. */
prot = (atrbuff[getattr(a)] & 0x2000) != 0;
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000) prot = (atrbuff[a] & 0x2000) != 0;
else if (!prot) {
curadr = a;
newcur();
return;
}
a++;
if (a == maxcnt) a = 0;
}
curadr = 0;
newcur();
break;
case 9: /* erase eof */
if (!fmtscrn) { /* unformatted screen */
kerr(2);
beep();
apikberr = sendFmtErr;
return;
}
/* else formatted screen */
if (atrbuff[curadr] & 0x8000) { /* cursor on attribute byte */
kerr(2);
beep();
apikberr = sendAttrErr;
return;
}
attroff = getattr(curadr);
if (atrbuff[attroff] & 0x2000) { /* protected */
kerr(2);
beep();
apikberr = sendProtErr;
return;
}
a = curadr; /* loop to store nulls */
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000) break; /* stop at attribute */
newchar(a, 0x00, 0, atrbuff[attroff]);
a++;
if (a == maxcnt) a = 0;
}
newwrite(0);
atrbuff[attroff] |= 0x0100; /* set MDT bit */
kerr(0);
break;
case 10: if (!fmtscrn) { /* erase input */
clrscn();
invldscr();
return;
}
b = 9999;
a = firstattr(); /* start at first attribute */
attroff = 0;
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000) { /* attribute */
prot = (atrbuff[a] & 0x2000) != 0;
if (!prot) atrbuff[a] &= 0xfeff; /* reset MDT */
attroff = a; /* save attribute offset */
}
else if (!prot) { /* character */
newchar(a, 0x00, 0, atrbuff[attroff]);
if (a < b) b = a; /* save first character */
}
a++;
if (a == maxcnt) a = 0;
}
newwrite(0);
if (b < 9999) curadr = b;
else curadr = 0;
newcur();
break;
case 11: insmode ^= 1; /* toggle insert mode */
newstat();
break;
case 12: if (fmtscrn) { /* delete character */
if (atrbuff[curadr] & 0x8000) { /* cursor on attribute byte */
kerr(2);
beep();
return;
}
i = atrbuff[attroff = getattr(curadr)];
if (i & 0x2000) { /* protected */
kerr(2);
beep();
return;
}
}
else i = 0;
a = curadr; /* first location to change */
/* calculate last location to change */
if (cs.repnull && fmtscrn) {
if (a > 0) b = a - 1;
else b = maxoff;
}
else {
b = ((curadr / scrhsize) + 1) * scrhsize - 1; /* last loc. on line */
}
while (a != b) {
next = a+1;
if (next == maxcnt) next = 0;
if (atrbuff[next] & 0x8000) break;
else {
newchar(a, chrbuff[next], atrbuff[next], i);
a = next;
}
}
newchar(a, 0x00, 0, i);
newwrite(0);
if (fmtscrn) atrbuff[attroff] |= 0x0100; /* set MDT bit */
kerr(0);
break;
case 13: kb_err = kblock = kblcode = insmode = 0; /* reset */
kbqsize = 0;
newstat();
break;
case 14: if (!fmtscrn) { /* dup */
if (insmode) if (cinsert()) { /* if insert, make room */
kerr(1);
beep(); /* error if no room */
return;
}
b = atrbuff[curadr] & 0xbf00;
newchar(curadr, 0x1c, b, 0);
newwrite(0);
curadr = 0;
newcur();
kerr(0);
return;
}
/* else formatted screen */
if (atrbuff[curadr] & 0x8000) { /* cursor on attribute byte */
kerr(2);
beep();
return;
}
attroff = getattr(curadr);
if (atrbuff[attroff] & 0x2000) { /* protected */
kerr(2);
beep();
return;
}
if (insmode) if (cinsert()) { /* if insert, make room */
kerr(1);
beep(); /* error if no room */
return;
}
b = atrbuff[curadr] & 0xbf00; /* update buffer and display */
newchar(curadr, 0x1c, b, atrbuff[attroff]);
newwrite(0);
atrbuff[attroff] |= 0x0100; /* set MDT bit */
kerr(0);
prot = 1;
a = curadr + 1;
if (a == maxcnt) a = 0; /* loop from next position */
for (i=0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000)
prot = (atrbuff[a] & 0x2000) != 0;
else if (!prot) {
curadr = a;
newcur();
return;
}
a++;
if (a == maxcnt) a = 0;
}
curadr = 0;
newcur();
break;
case 15: datakey(0x1e, 0); /* field mark */
break;
case 16: aplmode ^= 1; /* toggle APL mode */
fixbracket = cs.std_brack && (!aplmode) && (stdfont != ALAFONT);
newstat();
break;
case 17: /* insert blank */
a = curadr;
inschar = 1;
datakey(0x40, 0);
inschar = 0;
curadr = a;
newcur();
break;
case 18: /* rub out (non-std) */
a = curadr; /* get previous location */
a--;
if (a < 0) a = maxoff;
if (fmtscrn) {
if (atrbuff[a] & 0x8000) { /* attribute byte */
kerr(2);
beep();
return;
}
attroff = getattr(a);
if (atrbuff[attroff] & 0x2000) { /* protected */
kerr(2);
beep();
return;
}
}
curadr = a;
datakey(0x00, 0);
curadr = a;
newcur();
break;
case 19: curadr -= scrhsize * 2; /* up*2 */
if (curadr < 0) curadr += maxcnt;
newcur();
break;
case 20: curadr += scrhsize * 2; /* down */
if (curadr > maxoff) curadr -= maxcnt;
newcur();
break;
case 21: curadr-=2; /* left */
if (curadr < 0) curadr += maxcnt;
newcur();
break;
case 22: curadr+=2; /* right */
if (curadr > maxoff) curadr -=maxcnt;
newcur();
break;
case 23: cs.curpos ^= 1; /* cursor position */
newstat();
break;
default:
apikberr = sendOpErr;
break;
}
}
short getattr(offset)
short offset;
{
register short i;
for (i=0; i < maxcnt; i++) {
if (atrbuff[offset] & 0x8000) return(offset);
if (offset == 0) offset = maxoff;
else offset--;
}
return(offset);
}
short firstattr()
{
register short i;
for (i=0; i < maxcnt; i++) {
if (atrbuff[i] & 0x8000) return(i);
}
return(0); /* return 0 if no attributes (shouldn't be called this way) */
}
rdmod(lp_read)
char lp_read;
{
register unsigned short i, offset, j, k;
register unsigned char c, mod;
char modwrap; /* true if last modified field may wrap */
unsigned char addrbuff[2];
short copylen;
if (cs.repnull) nullreplace();
if (!fmtscrn) {
for (i=0; i < maxcnt; i++) {
if ((c = chrbuff[i]) == 0) continue;
if (rbsize > (rballoc-4)) {
if (tcpflg) {
senddata(0xf6, rbsize-3, readbuff+3, 1);
rbsize = 5;
}
else {
break;
}
}
if (atrbuff[i] & 0x4000)
if (!(((c == 0xad) || (c == 0xbd)) && fixbracket))
readbuff[rbsize++] = 0x08;
readbuff[rbsize++] = c;
if ((c == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
}
bufadr = 0;
if (tcpflg) addeor();
senddata(0xf6, rbsize-3, readbuff+3, 1);
return;
}
offset=firstattr();
for (i=0; i < maxcnt; i++) {
k = atrbuff[offset];
if (k & 0x8000) { /* handle attribute byte */
mod = 0;
modwrap = 0;
if (k & 0x0100) { /* MDT bit set */
if (!lp_read) {
mod = 1;
}
modwrap = 1;
j = offset+1;
if (j > maxoff) j = 0;
if ((rbsize > (rballoc-6)) && tcpflg) {
senddata(0xf6, rbsize-3, readbuff+3, 1);
rbsize = 5;
}
if (rbsize <= (rballoc-6)) {
readbuff[rbsize++] = 0x11;
ebcaddr(addrbuff, j); /* store 2-byte address */
copylen = 2;
tcpmovmem(addrbuff, readbuff+rbsize, ©len);
rbsize += copylen;
}
}
}
else if (mod) { /* handle data byte in modified field */
if ((c = chrbuff[offset]) != 0) {
if ((rbsize > (rballoc-4)) && tcpflg) {
senddata(0xf6, rbsize-3, readbuff+3, 1);
rbsize = 5;
}
if (rbsize <= (rballoc-4)) {
if (k & 0x4000) {
if (!(((c == 0xad) || (c == 0xbd)) && fixbracket)) {
readbuff[rbsize++] = 0x08;
}
}
readbuff[rbsize++] = c;
if ((c == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
}
}
}
offset++;
if (offset > maxoff) offset = 0;
}
bufadr = 0;
/* change buffer address if last modified field wraps */
if (modwrap && (offset != 0)) bufadr = offset;
if (tcpflg) addeor();
senddata(0xf6, rbsize-3, readbuff+3, 1);
}
rdbuff() /* read buffer */
{
register short i;
register unsigned char c, atrbyte;
unsigned char addrbuff[2];
short copylen;
readbuff[0] = 0xc2;
readbuff[5] = rdaid;
rbsize = 6;
if ((rdaid == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
/* append two-byte cursor address */
ebcaddr(addrbuff, curadr);
copylen = 2;
tcpmovmem(addrbuff, readbuff+rbsize, ©len);
rbsize += copylen;
if (cs.repnull) nullreplace();
for (i=0; i < maxcnt; i++) {
if (rbsize > (rballoc-4)) {
if (tcpflg) {
senddata(0xf2, rbsize-3, readbuff+3, 0);
rbsize = 5;
}
else {
break;
}
}
if (atrbuff[i] & 0x8000) { /* attribute byte */
readbuff[rbsize++] = 0x1d; /* start field */
atrbyte = (atrbuff[i] >> 8) & 0x3f;
readbuff[rbsize++] = ebc64[atrbyte]; /* attribute */
}
else {
c = chrbuff[i];
if (atrbuff[i] & 0x4000)
if (!(((c == 0xad) || (c == 0xbd)) && fixbracket))
readbuff[rbsize++] = 0x08;
readbuff[rbsize++] = c;
if ((c == IAC) && tcpflg) {
readbuff[rbsize++] = IAC;
}
}
}
bufadr = 0;
if (tcpflg) addeor();
senddata(0xf2, rbsize-3, readbuff+3, 0);
}
addeor()
{
if (rbsize > (rballoc-3)) {
senddata(0xf6, rbsize-3, readbuff+3, 1);
rbsize = 5;
}
readbuff[rbsize++] = IAC;
readbuff[rbsize++] = EOR;
}
short cinsert()
{
register unsigned char t;
register short a, b, c, i, n;
b = c = n = -1; /* -1 = no blank, character or null found */
a = curadr; /* scan to end of field or all bytes */
for (i = 0; i < maxcnt; i++) {
if (atrbuff[a] & 0x8000) break; /* stop at attribute byte */
t = chrbuff[a]; /* get charcter value */
/* do null to blank conversion if wanted */
if ((t == 0x00) && cs.repnull) t = 0x40;
if (t == 0x00) { /* found null */
n = a; /* remember where */
break; /* done now */
}
if (t == 0x40) b = i; /* remember last blank */
else c = i; /* remember last character */
a++;
if (a == maxcnt) a = 0;
}
if (n >= 0) a = n; /* use null if found */
else if ((b > c) && cs.impnull) { /* else use trailing blank */
a = curadr + b; /* (non-standard */
if (a > maxoff) a -= maxcnt;
}
else return(1); /* else return error */
if (fmtscrn) i = atrbuff[getattr(curadr)];
else i = 0;
while (a != curadr) { /* loop to shift bytes right */
b = a-1; /* get previous offset */
if (b < 0) b = maxoff;
newchar(a, chrbuff[b], atrbuff[b], i); /* define new values */
a--;
if (a < 0) a = maxoff;
}
return(0);
}
nullreplace()
{
register unsigned short i, offset, nullcount, a;
register unsigned char mod;
unsigned char *firstnull;
if (!fmtscrn) {
nullcount = 0;
for (i=0; i < maxcnt; i++) {
if (chrbuff[i] == 0) {
if (nullcount == 0) firstnull = chrbuff+offset;
nullcount++;
}
else {
while (nullcount > 0) {
(*firstnull) = 0x40;
firstnull++;
nullcount--;
}
}
}
return;
}
offset=firstattr();
for (i=0; i < maxcnt; i++) {
a = atrbuff[offset];
if (a & 0x8000) { /* handle attribute byte */
mod = 0;
if (a & 0x0100) { /* MDT bit set */
mod = 1;
nullcount = 0;
}
}
else if (mod) { /* handle data byte in modified field */
if (chrbuff[offset] == 0) {
if (nullcount == 0) firstnull = chrbuff+offset;
nullcount++;
}
else {
while (nullcount > 0) {
(*firstnull) = 0x40;
firstnull++;
nullcount--;
}
}
}
offset++;
if (offset > maxoff) offset = 0;
}
}
senddata(code, len, addr, lockflag)
unsigned char code;
short len;
char * addr;
char lockflag;
{
kb_err = 0;
if (tcpflg) {
if (lockflag) {
kblock = 1;
kblcode = 2;
}
tcpwrite(readbuff+5, rbsize-5);
return;
}
if (serflg == 0) {
readbuff[3] = NDATA;
readbuff[4] = code;
if (lockflag) {
kblock = 1;
kblcode = 2;
}
atpSndRequest(DATA, rbsize-3, readbuff+3);
return;
}
serattn();
if (lockflag) {
kblock = 1;
kblcode = 2;
newstat();
}
}
kerr(code)
short code;
{
if (code == kb_err) return;
kb_err = code;
newstat();
}
kbnew(chr, shift)
unsigned char chr, shift;
{
register unsigned char c, typ, val;
c = chr; /* get character */
/* define type, value for key */
typ = kbtyp[c] & 0x3f;
if (aplmode) val = kbapl[c];
else val = kbstd[c];
/* check for Enter or CLEAR to start new session */
if ((typ == 2) && ((val == 0x6d) || (val == 0x7d))) {
if (serflg) serlgin();
else if (tcpflg) tcplgin();
else netlgin();
return;
}
beep();
}
ebcaddr(buf, addr)
unsigned char *buf;
unsigned short addr;
{
if (addr14 && ewamode) { /* generate 14-bit address */
buf[0] = addr/256;
buf[0] &= 0x3f;
buf[1] = addr%256;
}
else { /* generate 12-bit address */
buf[0] = ebc64[addr/64];
buf[1] = ebc64[addr%64];
}
}